﻿@{
    string type = ViewData["type"] as string;
    string formatString;
    string timeStatement;
    if (type == "Day")
    {
        formatString = TBConfig.Instance().DayDateTimeFormat;
        timeStatement = "日期";
    }
    else
    {
        formatString = TBConfig.Instance().HourDateTimeFormat;
        timeStatement = "时间";
    }
}
<div class="contrl">
    <label>@timeStatement：</label>
    <input type="text" class="input time-input" name="timePoint" id="timePoint" onclick="WdatePicker({ dateFmt:'@formatString', el:'timePoint', isShowClear:false, readOnly:true})" value="@Convert.ToDateTime(ViewData["timePoint"]).ToString(formatString)">
    <button id="btnPreDay" class="btn" type="button">前一天</button>
    <button id="btnNextDay" class="btn" type="button">后一天</button>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        //前一天按钮点击事件
        $("#btnPreDay").click(function () {
            var d;
            if ($("#timePoint").val() == "") {
                d = new Date();
            }
            else {
                d = new Date($("#timePoint").val());
            }
            d.setTime(d.getTime() - 24 * 60 * 60 * 1000);
            var preDate = d.format("yyyy-MM-dd");
            $("#timePoint").val(preDate);
            @ViewData["JsFun"];
        });

        //后一天按钮点击事件
        $("#btnNextDay").click(function () {
            var d;
            if ($("#timePoint").val() == "") {
                d = new Date();
            }
            else {
                d = new Date($("#timePoint").val());
            }
            d.setTime(d.getTime() + 24 * 60 * 60 * 1000);
            var nextDate = d.format("yyyy-MM-dd");
            $("#timePoint").val(nextDate);
            @ViewData["JsFun"];
        });
    });
</script>